#include <iostream>
using namespace std;
int n;
char lan[1000005];
int c;
int j;
int dp[1000005];
int main() {
    cin >> n;
    dp[1] = 0;
    for (int i = 0; i < n; i++) {
        cin >> lan[i];
        if (lan[i] == 'C')
            c++;
        else
            j++;
    }

    if (j - c > 1 || c - j > 1) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    bool tag = 0;
    int s = 0, f = 1;
    while(f < n){
        while(f < n && lan[f] == lan[s]) f++;
        if(f > s+1){
            swap(lan[f], lan[s+1]);

        }else{
            s++; f++;
        }

    }

    return 0;
}
